/*
 * Selling Partner API for Solicitations
 * With the Solicitations API you can build applications that send non-critical solicitations to buyers. You can get a list of solicitation types that are available for an order that you specify, then call an operation that sends a solicitation to the buyer for that order. Buyers cannot respond to solicitations sent by this API, and these solicitations do not appear in the Messaging section of Seller Central or in the recipient's Message Center. The Solicitations API returns responses that are formed according to the <a href=https://tools.ietf.org/html/draft-kelly-json-hal-08>JSON Hypertext Application Language</a> (HAL) standard.
 *
 * OpenAPI spec version: v1
 *
 *
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen.git
 * Do not edit the class manually.
 */

package software.amazon.spapi.api.solicitations.v1;

import com.amazon.SellingPartnerAPIAA.LWAAccessTokenCache;
import com.amazon.SellingPartnerAPIAA.LWAAccessTokenCacheImpl;
import com.amazon.SellingPartnerAPIAA.LWAAuthorizationCredentials;
import com.amazon.SellingPartnerAPIAA.LWAAuthorizationSigner;
import com.amazon.SellingPartnerAPIAA.LWAException;
import com.amazon.SellingPartnerAPIAA.RestrictedDataTokenSigner;
import com.google.gson.reflect.TypeToken;
import io.github.bucket4j.Bucket;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import software.amazon.spapi.ApiCallback;
import software.amazon.spapi.ApiClient;
import software.amazon.spapi.ApiException;
import software.amazon.spapi.ApiResponse;
import software.amazon.spapi.Configuration;
import software.amazon.spapi.Pair;
import software.amazon.spapi.ProgressRequestBody;
import software.amazon.spapi.StringUtil;
import software.amazon.spapi.models.solicitations.v1.CreateProductReviewAndSellerFeedbackSolicitationResponse;
import software.amazon.spapi.models.solicitations.v1.GetSolicitationActionsForOrderResponse;

public class SolicitationsApi {
    private ApiClient apiClient;
    private Boolean disableRateLimiting;

    public SolicitationsApi(ApiClient apiClient, Boolean disableRateLimiting) {
        this.apiClient = apiClient;
        this.disableRateLimiting = disableRateLimiting;
    }

    private final Configuration config = Configuration.get();

    public final Bucket createProductReviewAndSellerFeedbackSolicitationBucket = Bucket.builder()
            .addLimit(config.getLimit("SolicitationsApi-createProductReviewAndSellerFeedbackSolicitation"))
            .build();

    public final Bucket getSolicitationActionsForOrderBucket = Bucket.builder()
            .addLimit(config.getLimit("SolicitationsApi-getSolicitationActionsForOrder"))
            .build();

    /**
     * Build call for createProductReviewAndSellerFeedbackSolicitation
     *
     * @param amazonOrderId An Amazon order identifier. This specifies the order for which a solicitation is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This specifies the marketplace in which the order was placed.
     *     Only one marketplace can be specified. (required)
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    private okhttp3.Call createProductReviewAndSellerFeedbackSolicitationCall(
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/solicitations/v1/orders/{amazonOrderId}/solicitations/productReviewAndSellerFeedback"
                .replaceAll("\\{" + "amazonOrderId" + "\\}", apiClient.escapeString(amazonOrderId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (marketplaceIds != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "marketplaceIds", marketplaceIds));

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {"application/hal+json"};
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {};

        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        return apiClient.buildCall(
                localVarPath,
                "POST",
                localVarQueryParams,
                localVarCollectionQueryParams,
                localVarPostBody,
                localVarHeaderParams,
                localVarFormParams,
                progressRequestListener);
    }

    private okhttp3.Call createProductReviewAndSellerFeedbackSolicitationValidateBeforeCall(
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        // verify the required parameter 'amazonOrderId' is set
        if (amazonOrderId == null) {
            throw new ApiException(
                    "Missing the required parameter 'amazonOrderId' when calling createProductReviewAndSellerFeedbackSolicitation(Async)");
        }
        // verify the required parameter 'marketplaceIds' is set
        if (marketplaceIds == null) {
            throw new ApiException(
                    "Missing the required parameter 'marketplaceIds' when calling createProductReviewAndSellerFeedbackSolicitation(Async)");
        }

        return createProductReviewAndSellerFeedbackSolicitationCall(
                amazonOrderId, marketplaceIds, progressRequestListener);
    }

    /**
     * Sends a solicitation to a buyer asking for seller feedback and a product review for the specified order. Send
     * only one productReviewAndSellerFeedback or free form proactive message per order. **Usage Plan:** | Rate
     * (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header
     * returns the usage plan rate limits that were applied to the requested operation, when available. The table above
     * indicates the default rate and burst values for this operation. Selling partners whose business demands require
     * higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage
     * Plans and Rate Limits in the Selling Partner
     * API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param amazonOrderId An Amazon order identifier. This specifies the order for which a solicitation is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This specifies the marketplace in which the order was placed.
     *     Only one marketplace can be specified. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return CreateProductReviewAndSellerFeedbackSolicitationResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public CreateProductReviewAndSellerFeedbackSolicitationResponse createProductReviewAndSellerFeedbackSolicitation(
            String amazonOrderId, List<String> marketplaceIds, String restrictedDataToken)
            throws ApiException, LWAException {
        ApiResponse<CreateProductReviewAndSellerFeedbackSolicitationResponse> resp =
                createProductReviewAndSellerFeedbackSolicitationWithHttpInfo(
                        amazonOrderId, marketplaceIds, restrictedDataToken);
        return resp.getData();
    }

    /**
     * Sends a solicitation to a buyer asking for seller feedback and a product review for the specified order. Send
     * only one productReviewAndSellerFeedback or free form proactive message per order. **Usage Plan:** | Rate
     * (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header
     * returns the usage plan rate limits that were applied to the requested operation, when available. The table above
     * indicates the default rate and burst values for this operation. Selling partners whose business demands require
     * higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage
     * Plans and Rate Limits in the Selling Partner
     * API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param amazonOrderId An Amazon order identifier. This specifies the order for which a solicitation is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This specifies the marketplace in which the order was placed.
     *     Only one marketplace can be specified. (required)
     * @return CreateProductReviewAndSellerFeedbackSolicitationResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public CreateProductReviewAndSellerFeedbackSolicitationResponse createProductReviewAndSellerFeedbackSolicitation(
            String amazonOrderId, List<String> marketplaceIds) throws ApiException, LWAException {
        ApiResponse<CreateProductReviewAndSellerFeedbackSolicitationResponse> resp =
                createProductReviewAndSellerFeedbackSolicitationWithHttpInfo(amazonOrderId, marketplaceIds, null);
        return resp.getData();
    }

    /**
     * Sends a solicitation to a buyer asking for seller feedback and a product review for the specified order. Send
     * only one productReviewAndSellerFeedback or free form proactive message per order. **Usage Plan:** | Rate
     * (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header
     * returns the usage plan rate limits that were applied to the requested operation, when available. The table above
     * indicates the default rate and burst values for this operation. Selling partners whose business demands require
     * higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage
     * Plans and Rate Limits in the Selling Partner
     * API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param amazonOrderId An Amazon order identifier. This specifies the order for which a solicitation is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This specifies the marketplace in which the order was placed.
     *     Only one marketplace can be specified. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return ApiResponse&lt;CreateProductReviewAndSellerFeedbackSolicitationResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<CreateProductReviewAndSellerFeedbackSolicitationResponse>
            createProductReviewAndSellerFeedbackSolicitationWithHttpInfo(
                    String amazonOrderId, List<String> marketplaceIds, String restrictedDataToken)
                    throws ApiException, LWAException {
        okhttp3.Call call =
                createProductReviewAndSellerFeedbackSolicitationValidateBeforeCall(amazonOrderId, marketplaceIds, null);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(
                    request, restrictedDataToken, "SolicitationsApi-createProductReviewAndSellerFeedbackSolicitation");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || createProductReviewAndSellerFeedbackSolicitationBucket.tryConsume(1)) {
            Type localVarReturnType =
                    new TypeToken<CreateProductReviewAndSellerFeedbackSolicitationResponse>() {}.getType();
            return apiClient.execute(call, localVarReturnType);
        } else
            throw new ApiException.RateLimitExceeded(
                    "createProductReviewAndSellerFeedbackSolicitation operation exceeds rate limit");
    }

    /**
     * Sends a solicitation to a buyer asking for seller feedback and a product review for the specified order. Send
     * only one productReviewAndSellerFeedback or free form proactive message per order. **Usage Plan:** | Rate
     * (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header
     * returns the usage plan rate limits that were applied to the requested operation, when available. The table above
     * indicates the default rate and burst values for this operation. Selling partners whose business demands require
     * higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage
     * Plans and Rate Limits in the Selling Partner
     * API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param amazonOrderId An Amazon order identifier. This specifies the order for which a solicitation is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This specifies the marketplace in which the order was placed.
     *     Only one marketplace can be specified. (required)
     * @return ApiResponse&lt;CreateProductReviewAndSellerFeedbackSolicitationResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<CreateProductReviewAndSellerFeedbackSolicitationResponse>
            createProductReviewAndSellerFeedbackSolicitationWithHttpInfo(
                    String amazonOrderId, List<String> marketplaceIds) throws ApiException, LWAException {
        return createProductReviewAndSellerFeedbackSolicitationWithHttpInfo(amazonOrderId, marketplaceIds, null);
    }

    /**
     * (asynchronously) Sends a solicitation to a buyer asking for seller feedback and a product review for the
     * specified order. Send only one productReviewAndSellerFeedback or free form proactive message per order. **Usage
     * Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60;
     * response header returns the usage plan rate limits that were applied to the requested operation, when available.
     * The table above indicates the default rate and burst values for this operation. Selling partners whose business
     * demands require higher throughput may see higher rate and burst values than those shown here. For more
     * information, see [Usage Plans and Rate Limits in the Selling Partner
     * API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param amazonOrderId An Amazon order identifier. This specifies the order for which a solicitation is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This specifies the marketplace in which the order was placed.
     *     Only one marketplace can be specified. (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call createProductReviewAndSellerFeedbackSolicitationAsync(
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<CreateProductReviewAndSellerFeedbackSolicitationResponse> callback)
            throws ApiException, LWAException {
        return createProductReviewAndSellerFeedbackSolicitationAsync(amazonOrderId, marketplaceIds, callback, null);
    }
    /**
     * (asynchronously) Sends a solicitation to a buyer asking for seller feedback and a product review for the
     * specified order. Send only one productReviewAndSellerFeedback or free form proactive message per order. **Usage
     * Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60;
     * response header returns the usage plan rate limits that were applied to the requested operation, when available.
     * The table above indicates the default rate and burst values for this operation. Selling partners whose business
     * demands require higher throughput may see higher rate and burst values than those shown here. For more
     * information, see [Usage Plans and Rate Limits in the Selling Partner
     * API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param amazonOrderId An Amazon order identifier. This specifies the order for which a solicitation is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This specifies the marketplace in which the order was placed.
     *     Only one marketplace can be specified. (required)
     * @param callback The callback to be executed when the API call finishes
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call createProductReviewAndSellerFeedbackSolicitationAsync(
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<CreateProductReviewAndSellerFeedbackSolicitationResponse> callback,
            String restrictedDataToken)
            throws ApiException, LWAException {

        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressRequestListener = callback::onUploadProgress;
        }

        okhttp3.Call call = createProductReviewAndSellerFeedbackSolicitationValidateBeforeCall(
                amazonOrderId, marketplaceIds, progressRequestListener);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(
                    request, restrictedDataToken, "SolicitationsApi-createProductReviewAndSellerFeedbackSolicitation");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || createProductReviewAndSellerFeedbackSolicitationBucket.tryConsume(1)) {
            Type localVarReturnType =
                    new TypeToken<CreateProductReviewAndSellerFeedbackSolicitationResponse>() {}.getType();
            apiClient.executeAsync(call, localVarReturnType, callback);
            return call;
        } else
            throw new ApiException.RateLimitExceeded(
                    "createProductReviewAndSellerFeedbackSolicitation operation exceeds rate limit");
    }
    /**
     * Build call for getSolicitationActionsForOrder
     *
     * @param amazonOrderId An Amazon order identifier. This specifies the order for which you want a list of available
     *     solicitation types. (required)
     * @param marketplaceIds A marketplace identifier. This specifies the marketplace in which the order was placed.
     *     Only one marketplace can be specified. (required)
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    private okhttp3.Call getSolicitationActionsForOrderCall(
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/solicitations/v1/orders/{amazonOrderId}"
                .replaceAll("\\{" + "amazonOrderId" + "\\}", apiClient.escapeString(amazonOrderId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (marketplaceIds != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "marketplaceIds", marketplaceIds));

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {"application/hal+json"};
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {};

        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        return apiClient.buildCall(
                localVarPath,
                "GET",
                localVarQueryParams,
                localVarCollectionQueryParams,
                localVarPostBody,
                localVarHeaderParams,
                localVarFormParams,
                progressRequestListener);
    }

    private okhttp3.Call getSolicitationActionsForOrderValidateBeforeCall(
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        // verify the required parameter 'amazonOrderId' is set
        if (amazonOrderId == null) {
            throw new ApiException(
                    "Missing the required parameter 'amazonOrderId' when calling getSolicitationActionsForOrder(Async)");
        }
        // verify the required parameter 'marketplaceIds' is set
        if (marketplaceIds == null) {
            throw new ApiException(
                    "Missing the required parameter 'marketplaceIds' when calling getSolicitationActionsForOrder(Async)");
        }

        return getSolicitationActionsForOrderCall(amazonOrderId, marketplaceIds, progressRequestListener);
    }

    /**
     * Returns a list of solicitation types that are available for an order that you specify. A solicitation type is
     * represented by an actions object, which contains a path and query parameter(s). You can use the path and
     * parameter(s) to call an operation that sends a solicitation. Currently only the
     * productReviewAndSellerFeedbackSolicitation solicitation type is available. **Usage Plan:** | Rate (requests per
     * second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the
     * usage plan rate limits that were applied to the requested operation, when available. The table above indicates
     * the default rate and burst values for this operation. Selling partners whose business demands require higher
     * throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and
     * Rate Limits in the Selling Partner
     * API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param amazonOrderId An Amazon order identifier. This specifies the order for which you want a list of available
     *     solicitation types. (required)
     * @param marketplaceIds A marketplace identifier. This specifies the marketplace in which the order was placed.
     *     Only one marketplace can be specified. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return GetSolicitationActionsForOrderResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public GetSolicitationActionsForOrderResponse getSolicitationActionsForOrder(
            String amazonOrderId, List<String> marketplaceIds, String restrictedDataToken)
            throws ApiException, LWAException {
        ApiResponse<GetSolicitationActionsForOrderResponse> resp =
                getSolicitationActionsForOrderWithHttpInfo(amazonOrderId, marketplaceIds, restrictedDataToken);
        return resp.getData();
    }

    /**
     * Returns a list of solicitation types that are available for an order that you specify. A solicitation type is
     * represented by an actions object, which contains a path and query parameter(s). You can use the path and
     * parameter(s) to call an operation that sends a solicitation. Currently only the
     * productReviewAndSellerFeedbackSolicitation solicitation type is available. **Usage Plan:** | Rate (requests per
     * second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the
     * usage plan rate limits that were applied to the requested operation, when available. The table above indicates
     * the default rate and burst values for this operation. Selling partners whose business demands require higher
     * throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and
     * Rate Limits in the Selling Partner
     * API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param amazonOrderId An Amazon order identifier. This specifies the order for which you want a list of available
     *     solicitation types. (required)
     * @param marketplaceIds A marketplace identifier. This specifies the marketplace in which the order was placed.
     *     Only one marketplace can be specified. (required)
     * @return GetSolicitationActionsForOrderResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public GetSolicitationActionsForOrderResponse getSolicitationActionsForOrder(
            String amazonOrderId, List<String> marketplaceIds) throws ApiException, LWAException {
        ApiResponse<GetSolicitationActionsForOrderResponse> resp =
                getSolicitationActionsForOrderWithHttpInfo(amazonOrderId, marketplaceIds, null);
        return resp.getData();
    }

    /**
     * Returns a list of solicitation types that are available for an order that you specify. A solicitation type is
     * represented by an actions object, which contains a path and query parameter(s). You can use the path and
     * parameter(s) to call an operation that sends a solicitation. Currently only the
     * productReviewAndSellerFeedbackSolicitation solicitation type is available. **Usage Plan:** | Rate (requests per
     * second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the
     * usage plan rate limits that were applied to the requested operation, when available. The table above indicates
     * the default rate and burst values for this operation. Selling partners whose business demands require higher
     * throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and
     * Rate Limits in the Selling Partner
     * API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param amazonOrderId An Amazon order identifier. This specifies the order for which you want a list of available
     *     solicitation types. (required)
     * @param marketplaceIds A marketplace identifier. This specifies the marketplace in which the order was placed.
     *     Only one marketplace can be specified. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return ApiResponse&lt;GetSolicitationActionsForOrderResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<GetSolicitationActionsForOrderResponse> getSolicitationActionsForOrderWithHttpInfo(
            String amazonOrderId, List<String> marketplaceIds, String restrictedDataToken)
            throws ApiException, LWAException {
        okhttp3.Call call = getSolicitationActionsForOrderValidateBeforeCall(amazonOrderId, marketplaceIds, null);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(
                    request, restrictedDataToken, "SolicitationsApi-getSolicitationActionsForOrder");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || getSolicitationActionsForOrderBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<GetSolicitationActionsForOrderResponse>() {}.getType();
            return apiClient.execute(call, localVarReturnType);
        } else throw new ApiException.RateLimitExceeded("getSolicitationActionsForOrder operation exceeds rate limit");
    }

    /**
     * Returns a list of solicitation types that are available for an order that you specify. A solicitation type is
     * represented by an actions object, which contains a path and query parameter(s). You can use the path and
     * parameter(s) to call an operation that sends a solicitation. Currently only the
     * productReviewAndSellerFeedbackSolicitation solicitation type is available. **Usage Plan:** | Rate (requests per
     * second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the
     * usage plan rate limits that were applied to the requested operation, when available. The table above indicates
     * the default rate and burst values for this operation. Selling partners whose business demands require higher
     * throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and
     * Rate Limits in the Selling Partner
     * API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param amazonOrderId An Amazon order identifier. This specifies the order for which you want a list of available
     *     solicitation types. (required)
     * @param marketplaceIds A marketplace identifier. This specifies the marketplace in which the order was placed.
     *     Only one marketplace can be specified. (required)
     * @return ApiResponse&lt;GetSolicitationActionsForOrderResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<GetSolicitationActionsForOrderResponse> getSolicitationActionsForOrderWithHttpInfo(
            String amazonOrderId, List<String> marketplaceIds) throws ApiException, LWAException {
        return getSolicitationActionsForOrderWithHttpInfo(amazonOrderId, marketplaceIds, null);
    }

    /**
     * (asynchronously) Returns a list of solicitation types that are available for an order that you specify. A
     * solicitation type is represented by an actions object, which contains a path and query parameter(s). You can use
     * the path and parameter(s) to call an operation that sends a solicitation. Currently only the
     * productReviewAndSellerFeedbackSolicitation solicitation type is available. **Usage Plan:** | Rate (requests per
     * second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the
     * usage plan rate limits that were applied to the requested operation, when available. The table above indicates
     * the default rate and burst values for this operation. Selling partners whose business demands require higher
     * throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and
     * Rate Limits in the Selling Partner
     * API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param amazonOrderId An Amazon order identifier. This specifies the order for which you want a list of available
     *     solicitation types. (required)
     * @param marketplaceIds A marketplace identifier. This specifies the marketplace in which the order was placed.
     *     Only one marketplace can be specified. (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call getSolicitationActionsForOrderAsync(
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<GetSolicitationActionsForOrderResponse> callback)
            throws ApiException, LWAException {
        return getSolicitationActionsForOrderAsync(amazonOrderId, marketplaceIds, callback, null);
    }
    /**
     * (asynchronously) Returns a list of solicitation types that are available for an order that you specify. A
     * solicitation type is represented by an actions object, which contains a path and query parameter(s). You can use
     * the path and parameter(s) to call an operation that sends a solicitation. Currently only the
     * productReviewAndSellerFeedbackSolicitation solicitation type is available. **Usage Plan:** | Rate (requests per
     * second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the
     * usage plan rate limits that were applied to the requested operation, when available. The table above indicates
     * the default rate and burst values for this operation. Selling partners whose business demands require higher
     * throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and
     * Rate Limits in the Selling Partner
     * API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param amazonOrderId An Amazon order identifier. This specifies the order for which you want a list of available
     *     solicitation types. (required)
     * @param marketplaceIds A marketplace identifier. This specifies the marketplace in which the order was placed.
     *     Only one marketplace can be specified. (required)
     * @param callback The callback to be executed when the API call finishes
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call getSolicitationActionsForOrderAsync(
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<GetSolicitationActionsForOrderResponse> callback,
            String restrictedDataToken)
            throws ApiException, LWAException {

        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressRequestListener = callback::onUploadProgress;
        }

        okhttp3.Call call = getSolicitationActionsForOrderValidateBeforeCall(
                amazonOrderId, marketplaceIds, progressRequestListener);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(
                    request, restrictedDataToken, "SolicitationsApi-getSolicitationActionsForOrder");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || getSolicitationActionsForOrderBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<GetSolicitationActionsForOrderResponse>() {}.getType();
            apiClient.executeAsync(call, localVarReturnType, callback);
            return call;
        } else throw new ApiException.RateLimitExceeded("getSolicitationActionsForOrder operation exceeds rate limit");
    }

    public static class Builder {
        private LWAAuthorizationCredentials lwaAuthorizationCredentials;
        private String endpoint;
        private LWAAccessTokenCache lwaAccessTokenCache;
        private Boolean disableAccessTokenCache = false;
        private Boolean disableRateLimiting = false;

        public Builder lwaAuthorizationCredentials(LWAAuthorizationCredentials lwaAuthorizationCredentials) {
            this.lwaAuthorizationCredentials = lwaAuthorizationCredentials;
            return this;
        }

        public Builder endpoint(String endpoint) {
            this.endpoint = endpoint;
            return this;
        }

        public Builder lwaAccessTokenCache(LWAAccessTokenCache lwaAccessTokenCache) {
            this.lwaAccessTokenCache = lwaAccessTokenCache;
            return this;
        }

        public Builder disableAccessTokenCache() {
            this.disableAccessTokenCache = true;
            return this;
        }

        public Builder disableRateLimiting() {
            this.disableRateLimiting = true;
            return this;
        }

        public SolicitationsApi build() {
            if (lwaAuthorizationCredentials == null) {
                throw new RuntimeException("LWAAuthorizationCredentials not set");
            }

            if (StringUtil.isEmpty(endpoint)) {
                throw new RuntimeException("Endpoint not set");
            }

            LWAAuthorizationSigner lwaAuthorizationSigner = null;
            if (disableAccessTokenCache) {
                lwaAuthorizationSigner = new LWAAuthorizationSigner(lwaAuthorizationCredentials);
            } else {
                if (lwaAccessTokenCache == null) {
                    lwaAccessTokenCache = new LWAAccessTokenCacheImpl();
                }
                lwaAuthorizationSigner = new LWAAuthorizationSigner(lwaAuthorizationCredentials, lwaAccessTokenCache);
            }

            return new SolicitationsApi(
                    new ApiClient()
                            .setLWAAuthorizationSigner(lwaAuthorizationSigner)
                            .setBasePath(endpoint),
                    disableRateLimiting);
        }
    }
}
